import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Struct;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class main {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Hello world");
		
		/*List list;
		
		Set set1 = new TreeSet<Integer>();
		set1.add(4);
		set1.add(1);
		set1.add(3);
		set1.add(2);
				
		Iterator iter = set1.iterator();
		while(iter.hasNext()){
			int value = (Integer) iter.next();
			System.out.println(value);
		}*/
		
		int n = nhapSonguyen("Nhap so ptu mang:");
		System.out.println("Gia tri vua nhap: " + n );

		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			
			a[i] = nhapSonguyen("a[" + i + "]:" );
		}
	
		//goi ham xuat mang
		xuatmang(a);
		
	}

	private static int nhapSonguyen(String message){		
		
		BufferedReader read = new BufferedReader( new InputStreamReader(System.in) );
		
		int val = 0;
		try {			
			String text = "";
			boolean flag = false;			
			System.out.print(message);
			while(true){			
				try {					
//					read.mark(0);
					text = read.readLine();										
					val = Integer.parseInt(text);
					flag = true;
				} catch (Exception e) {
//					e.printStackTrace();
					System.out.print("\nNhap sai vui long nhap lai: ");		
				}
				
				if (flag) {
					break;
				}
			}
						
		} catch (Exception e) {
			e.printStackTrace();
		}
				
//		try {
//			read.close();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
		
		return val;
		
	}
	
	private static void xuatmang(int a[]){
		if (a==null) {
			return;
		}
		
		for (int i = 0; i < a.length; i++) {
			System.out.println("a[" + i + "] = " + a[i]);
		}
		
	}
	
}
